package com.matrix.java.chap_06;

/*
    生成随机字符
 */
public class Ex6_38 {
    public static void main(String[] args) {
        int count = 1;
        int countLetter = 0;
        for (int i = 0; i < 200; i++) {
            char output;
            int randomNum = (int) (Math.random() *2);
            if (randomNum == 0 && countLetter < 100) {
                output = getRandomUpperCaseLetter();
                countLetter++;
            } else{
                output = getRandomDigitCharacter();
            }
            if (count % 10 != 0) {
                System.out.print(output + "\t");
            } else {
                System.out.println(output);
            }
            count++;
        }
    }

    public static char getRandomCharacter(char ch1, char ch2) {
        return (char) (ch1 + Math.random() * (ch2 - ch1 + 1));
    }

    public static char getRandomUpperCaseLetter() {
        return getRandomCharacter('A', 'Z');
    }

    public static char getRandomDigitCharacter() {
        return getRandomCharacter('0', '9');
    }
}
